package com.nbsaas.boot.job.rest.convert;

import com.nbsaas.boot.job.data.entity.Job;
import com.nbsaas.boot.job.api.domain.request.JobRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.jpa.data.entity.User;

/**
* 职位请求对象转换成实体对象
*/

public class JobEntityConvert  implements Converter<Job, JobRequest> {

    @Override
    public Job convert(JobRequest source) {
        Job result = new Job();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getCreator()!=null){
                    User creator =new User();
                    creator.setId(source.getCreator());
                    result.setCreator(creator);
                    }
        return result;
    }
}

